package com.simple.core.validate;

import cn.hutool.core.util.IdcardUtil;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author : mocun
 * @since : 2023/3/22
 */

public class IsIdentityCardValidator implements ConstraintValidator<IsIdentityCard, String> {

    @Override
    public void initialize(IsIdentityCard constraintAnnotation) {
        //do nothing
    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        return IdcardUtil.isValidCard(value);
    }
}
